#!/bin/sh


#1.docker安装包制作

echo "remove exit c_pemd container"
result=`docker ps -a| grep c_pemd | wc -l`
if [ $result != 0 ] 
then
	echo "stop container"
 	container stop c_pemd
	container uninstall c_pemd
fi

if [ ! -d "/data/app/pemd/conf" ];then
	mkdir -p /data/app/pemd/conf
fi

if [ ! -d "/data/app/pemd/log" ];then
	mkdir -p /data/app/pemd/log
fi

if [ ! -d "/data/app/pemd/data" ];then
	mkdir -p /data/app/pemd/data
fi

echo "copy config to /data/app/pemd"
if [ -f "conf/settings.conf" ]
then
	if [ ! -f "/data/app/pemd/conf/settings.conf" ]
	then
		cp -rf conf/settings.conf /data/app/pemd/conf/
	fi
fi

echo "Install c_pemd Docker (c_pemd)......"

sudo container install c_pemd ./pemd.tar \
		-dev /dev/ttyRS0:/dev/ttyRS0 \
        -dev /dev/ttyRS1:/dev/ttyRS1 \
        -dev /dev/ttyRS2:/dev/ttyRS2 \
        -dev /dev/ttyRS3:/dev/ttyRS3 \
    	-v /data/app/:/data/app/
